package ${object.javaPackagePath}service.impl.${object.moduleName};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ${object.javaPackagePath}core.service.impl.BaseServiceImpl;
import ${object.javaPackagePath}dao.${object.moduleName}.I${table.className}Dao;
import ${object.javaPackagePath}entity.${object.moduleName}.${table.className};
import ${object.javaPackagePath}service.${object.moduleName}.I${table.className}Service;


<#if table.cnName??>
/**
 * @describe ${object.describe}
 * @author ${object.author}
 * @version ${object.version}
 * @date ${object.createTime}
 **/
</#if>
<#list table.pkCloums as pk>
@Service
public class ${table.className}ServiceImpl extends BaseServiceImpl<${table.className}, ${pk.javaType?substring(10)}> implements I${table.className}Service {
	
    @Autowired
    private I${table.className}Dao ${table.varName}Dao;
	
	@Override
	public void save(${table.className} ${table.varName}) {
	   <#if pk.javaType == "java.lang.Integer">
	    if (${table.varName}.getId() == null || ${table.varName}.getId() == 0) {
            ${table.varName}Dao.insertSelective(${table.varName});
        } else {
            ${table.varName}Dao.updateByPrimaryKeySelective(${table.varName});
        }
	   <#elseif pk.javaType == "java.lang.String">
        if (${table.varName}.getId() != null) {
            ${table.varName}Dao.updateSelective(${table.varName});
        } else {
            ${table.varName}.setId(UUIDUtils.uuid());
            ${table.varName}Dao.insertSelective(${table.varName});
        }
	   </#if>
	}
}
</#list>

